package sk.fiit.icp.eventmanager.view;

import java.util.Date;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import sk.fiit.icp.components.HeaderSignedPanel;
import sk.fiit.icp.components.Utils;
import sk.fiit.icp.event.view.EventPanel;

public class EventManagerPage extends WebPage {
	int eventId = 0;
	int window = 0;
	String startT = Utils.dateToJSString( new Date() );
	String endT = Utils.dateToJSString( new Date() );
	EventPanel panel = null;

	public EventManagerPage(final PageParameters params) {

		if ( !params.isEmpty() && params.get( "eventId" ) != null && Integer.valueOf( params.get( "eventId" ).toString() ).intValue() > 0 ) {
			eventId = Integer.valueOf( params.get( "eventId" ).toString() ).intValue();
		}

		if ( !params.isEmpty() && params.get( "iswindow" ) != null ) {
			window = Integer.valueOf( params.get( "iswindow" ).toString() ).intValue();
		}

		if ( !params.isEmpty() && params.get( "startTime" ) != null ) {
			startT = params.get( "startTime" ).toString();
		}

		if ( !params.isEmpty() && params.get( "endTime" ) != null ) {
			endT = params.get( "endTime" ).toString();
		}
		this.panel = new EventPanel( "bodyPanel", eventId, window, startT, endT );
		this.panel.setOutputMarkupId( true );
		add( new HeaderSignedPanel( "header" ) );
		add( new EventManagerNavigation( "navigation", this.panel ) );
		add( this.panel );

	}

}
